package com.geek.servlet.filter;


import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(urlPatterns = "/*")
public class CharacterEncodeFilter implements Filter {
  @Override
  public void init(final FilterConfig filterConfig) throws ServletException {

  }

  @Override
  public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
    // 让浏览器用utf8来解析返回的数据
    response.setContentType("text/html;charset=UTF-8");
    chain.doFilter(request,response);
  }

  @Override
  public void destroy() {

  }
}
